-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX #7777, #7776]: Generate valid code if comment exists before closing brace #7858
Conversation
@@ -945,6 +945,44 @@ class Bar | |||
RUBY | |||
end | |||
|
|||
it 'correct multiline array brace without crashing' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it 'correct multiline array brace without crashing' do | |
it 'corrects multiline array brace without crashing' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
second_key: 'value c' | ||
} | ||
RUBY | ||
expect(cli.run(['--auto-correct'])).to eq(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(cli.run(['--auto-correct'])).to eq(1) | |
expect(cli.run(['--auto-correct'])).to eq(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
RUBY | ||
end | ||
|
||
it 'correct multiline literal brace without crashing' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it 'correct multiline literal brace without crashing' do | |
it 'corrects multiline literal brace without crashing' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
'hash' => {'key' => 'value'} # comment | ||
)) | ||
RUBY | ||
expect(cli.run(['--auto-correct'])).to eq(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(cli.run(['--auto-correct'])).to eq(0) | |
expect(cli.run(['--auto-correct'])).to eq(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
4099bbf
to
6549a24
Compare
6549a24
to
313df45
Compare
@@ -945,6 +945,46 @@ class Bar | |||
RUBY | |||
end | |||
|
|||
it 'corrects multiline array brace without crashing' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why didn't you add those tests to the spec of the cop instead? It seems to me this is the natural place for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bbatsov PR is ready for review.
a2485a1
to
344fd63
Compare
) | ||
end | ||
|
||
def closing_brace_content(corrector, node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the names closing_brace_content
and trailing_content_of_closing_brace
are a bit confusing, as braces can't really have content. The naming should be improved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bbatsov changes done. Please review now.
344fd63
to
b92004c
Compare
b2e1945
to
60598a5
Compare
60598a5
to
e9c2c2a
Compare
e9c2c2a
to
de65e13
Compare
@bbatsov this is kind reminder to you. Please review and let me know if any changes required. |
closes #7777 and #7776
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.